package com.bluesky.service;

import com.bluesky.ds.ReadWrite;
import com.bluesky.ds.ReadWriteRoutingStrategy;
import com.bluesky.mapper.UserMapper;
import com.bluesky.po.UserPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public UserPO getUser(Integer id) {
        return userMapper.getUser(id);
    }

    @ReadWrite(ReadWriteRoutingStrategy.MASTER)
    public UserPO getUserFromMaster(){
      return   this.userMapper.getUser(1);
    }

    @ReadWrite(ReadWriteRoutingStrategy.SLAVE)
    public UserPO getUserFromSlave(){
        return   this.userMapper.getUser(1);
    }
}
